package at.ac.tuwien.dse.health.geo;

import at.ac.tuwien.dse.health.entity.GeoHospital;
import org.springframework.data.mongodb.core.geo.*;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.math.BigInteger;
import java.util.List;

/**
 * Uses MongoDB for querying {@link GeoHospital GeoHospitals} within a certain geographical location.
 *
 * @author Bernhard Nickel
 * @author Gregor Schauer
 * @author Dominik Strasser
 */
public interface GeoHospitalRepository extends MongoRepository<GeoHospital, BigInteger> {
	/**
	 * Finds all {@link GeoHospital GeoHospitals} within the given radius.
	 *
	 * @param c the area to search
	 * @return the hospitals found
	 */
	List<GeoHospital> findByLocationWithin(Circle c);

	/**
	 * Finds all {@link GeoHospital GeoHospitals} located within a given rectangular area.
	 *
	 * @param are the area to search
	 * @return the hospitals found
	 */
	List<GeoHospital> findByLocationWithin(Box are);

	/**
	 * Finds all {@link GeoHospital GeoHospitals} within the given radius.
	 *
	 * @param point    the target coordinate
	 * @param distance the maximum distance
	 * @return the hospitals found
	 */
	GeoResults<GeoHospital> findByLocationNear(Point point, Distance distance);
}
